<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>split</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_2068">&nbsp;</a>NAME</h4><blockquote>
split - split files into pieces
</blockquote><h4><a name = "tag_001_014_2069">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

split <b>[</b>-l <i>line_count</i><b>][</b>-a <i>suffix_length</i><b>][</b><i>file</i><b>[</b><i>name</i><b>]]</b>

split -b <i>n</i><b>[</b>k|m<b>][</b>-a <i>suffix_length</i><b>][</b><i>file</i><b>[</b><i>name</i><b>]]</b>

split <b>[</b>-<i>line_count</i><b>][</b>-a <i>suffix_length</i><b>][</b><i>file</i><b>[</b><i>name</i><b>]]</b>
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2070">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>split</i>
utility reads an
input file and writes one or more output files.
The default size of each output file is 1000 lines.
The size of the output files can be modified by
specification of the
<b>-b</b>
or
<b>-l</b>
options.
Each output file is created with a unique suffix.
The suffix consists of exactly
<i>suffix_length</i>
lower-case letters from the
POSIX locale.
The letters of the suffix are used as if they
were a base-26 digit system, with the first suffix to be
created consisting of all
a
characters, the second with a
b
replacing
the last
a,
and so on, until a name of all
z
characters
is created.
By default, the names of the output files are
x,
followed by a two-character suffix from the character set as
described above, starting with
aa,
ab,
ac,
and so on, and continuing until the suffix
zz,
for a maximum of 676 files.
<p>
If the number of files required
exceeds the maximum allowed by the suffix length provided,
such that the last allowable file would
be larger than the requested size, the
<i>split</i>
utility will fail after creating the last file
with a valid suffix;
<i>split</i>
will not delete the files it created
with valid suffixes.
If the file limit is not exceeded, the last file created will contain
the remainder of the input file, and may be smaller than the
requested size.
</blockquote><h4><a name = "tag_001_014_2071">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>split</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> 
except that the obsolescent version allows a multi-digit option,
<b>-</b><i>line_count</i>.
<p>
The following options are supported:
<dl compact>

<dt><b>-a&nbsp;</b><i>suffix_length</i>
<dd>
Use
<i>suffix_length</i>
letters to form the suffix portion of the filenames
of the split file.
If
<b>-a</b>
is not specified, the default suffix length is two.
If the sum of the
<i>name</i>
operand and the
<i>suffix_length</i>
option-argument would create a filename exceeding
{NAME_MAX}
bytes, an error will result;
<i>split</i>
will exit with a diagnostic message
and no files will be created.

<dt><b>-b&nbsp;</b><i>n</i>
<dd>Split a file into pieces
<i>n</i>
bytes in size.

<dt><b>-b </b><i>n</i><b>k</b><dd>Split a file into pieces
<i>n</i>*1024
bytes in size.

<dt><b>-b </b><i>n</i><b>m</b><dd>Split a file into pieces
<i>n</i>*1048576
bytes in size.


<dt><b>-l&nbsp;</b><i>line_count</i>
<dd>
<dt><i>-line_count</i><dd>
Specify the number of lines in each resulting file piece.
The
<i>line_count</i>
argument is an unsigned decimal integer.
The default is 1000.
If the input does not end with a
newline character,
the partial line will be included in the last output file.

</dl>
</blockquote><h4><a name = "tag_001_014_2072">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt><i>file</i><dd>The pathname of the ordinary file to be split.
If no input file is given
or
<i>file</i>
is "-", the standard input will be used.


<dt><i>name</i><dd>The prefix to be used for each of the files resulting from
the split operation.
If no
<i>name</i>
argument is given,
x
will be used as the prefix of the output files.
The combined length of the basename of
<i>prefix</i>
and
<i>suffix_length</i>
cannot exceed
{NAME_MAX}
bytes; see the OPTIONS section.

</dl>
</blockquote><h4><a name = "tag_001_014_2073">&nbsp;</a>STDIN</h4><blockquote>
See the INPUT FILES section.
</blockquote><h4><a name = "tag_001_014_2074">&nbsp;</a>INPUT FILES</h4><blockquote>
Any file can be used as input.
</blockquote><h4><a name = "tag_001_014_2075">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>split</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments and input files).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_2076">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_2077">&nbsp;</a>STDOUT</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_2078">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_2079">&nbsp;</a>OUTPUT FILES</h4><blockquote>
The output files contain portions of the original input file,
otherwise unchanged.
</blockquote><h4><a name = "tag_001_014_2080">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2081">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>Successful completion.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_2082">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_2083">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
<br>
</blockquote><h4><a name = "tag_001_014_2084">&nbsp;</a>EXAMPLES</h4><blockquote>
In the following examples
foo
is a text file that contains 5000 lines.
<ol>
<p>
<li>
Create five files,
xaa,
xab,
xac,
xad
and
xae:
<pre>
<code>
split foo
</code>
</pre>
<p>
<li>
Create five files, but the suffixed portion of the created
files consists of three letters,
xaaa,
xaab,
xaac,
xaad
and
xaae:
<pre>
<code>
split -a 3 foo
</code>
</pre>
<p>
<li>
Create three files with four-letter suffixes
and a supplied prefix,
bar_aaaa,
bar_aaab
and
bar_aaac:
<pre>
<code>
split -a 4 -l 2000 foo bar_
</code>
</pre>
<p>
<li>
Create as many files as are necessary to contain at most
20*1024 bytes, each with the default prefix of
<b>x</b>
and a five-letter suffix:
<pre>
<code>
split -a 5 -b 20k foo
</code>
</pre>
<p>
</ol>
</blockquote><h4><a name = "tag_001_014_2085">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2086">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="csplit.html">csplit</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
